package com.example.bootdemo.controller;

import com.example.bootdemo.entity.TUser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.*;

@Controller
@RequestMapping("/frm")
public class FrmController {



    @RequestMapping("/frmTest1")
    public String frmTest1(Model model) {
        return "frmTest1";
    }

    @RequestMapping("/frmTest2")
    public String frmTest2(Model model){
        Map map = new LinkedHashMap<>();
        for (int i = 0; i < 5; i++) {
            map.put("key" + i, "value" + i);
        }
        model.addAttribute("list", Arrays.asList("string1", "string2", "string3", "string4", "string5", "string6"));
        model.addAttribute("map", map);
        model.addAttribute("name", "   htTps://wWw.zHyD.mE   ");
        model.addAttribute("htmlText", "<span style=\"color: red;font-size: 16px;\">html内容</span>");
        model.addAttribute("num", 123.012);
        model.addAttribute("null", null);
        model.addAttribute("dateObj", new Date());
        model.addAttribute("bol", true);
        return "frmTest2";
    }

    @RequestMapping("/frmTest3")
    public String frmTest3(Model model){
        Map<String ,Object> map = new HashMap<>();
        List<Object> list = new ArrayList();
        map.clear();
        map.put("id","12345678");
        map.put("name","yejing");
        list.add(2);
        list.add(4);
        list.add(6);
        list.add(8);
        list.add(10);
        map.put("aa",null);
        model.addAttribute("map",map);
        model.addAttribute("list",list);
        model.addAttribute("date",new Date());




        // Map操作
        Map<String,String> cityMap = new HashMap<>();
        cityMap.put("sh","上海");
        cityMap.put("bj","北京");
        cityMap.put("sz","深圳");
        model.addAttribute("cityMap",cityMap);

        return "frmTest3";
    }
}
